#ifndef SCOPEDLOCKERS_H
#define SCOPEDLOCKERS_H

#include "Mutex.h"
#include "criticalsection.h"

namespace syncLib
{

    template <class LockerType>
    class ScopedLocker
    {
    public:
        explicit ScopedLocker(LockerType& locker)
            : mLocker_(locker)
        {
            mLocker_.Lock();
        }

        ~ScopedLocker()
        {
            mLocker_.UnLock();
        }

    private:
        LockerType& mLocker_;
    };

    typedef ScopedLocker<Mutex> AutoMutex;
    typedef ScopedLocker<CriticalSection> AutoCriticalSection;

};

#endif // SCOPEDLOCKERS_H
